package net.chrisrichardson.ec2deployer.applications

import org.apache.commons.logging.*
import net.chrisrichardson.ec2deployer.cluster.WebServerTier

/**
 A builder for creating the CATALINA_OPTS used to launch tomcat
*/

class CatalinaOptionsBuilder {

    Log logger = LogFactory.getLog(getClass())
    private StringBuffer sb = new StringBuffer()
    WebServerTier webServerTier

    /**
    Specify a JVM command line argument
    */

    def arg(String s) {
        sb << " " << s
        this
    }

    /**
    Specify a system property
    */
    
    def prop(String name, value = null) {
        sb << " -D" << name
        if (value != null) {
            sb << "=" << value.toString()
        }
        this
    }

    def getOptions() {
        logger.debug sb.toString()
        sb.toString()
    }


}